package com.servlet.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 登录
 * @author smfx1314
 *
 */
@WebServlet("/userLogin")
public class UserLogin extends HttpServlet {
	private static final long serialVersionUID = 1L;
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String username = request.getParameter("username");
		String password = request.getParameter("password");
		if("admin".equals(username) && "1234".equals(password)){
			request.getSession().setAttribute("username", username);
			response.sendRedirect("listUser.do");
		}else{
			request.getSession().setAttribute("msg", "用户名或密码不对");
			request.getRequestDispatcher("index.jsp").forward(request, response);;
		}
	}

}
